package com.roncoo.education.course.service.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.roncoo.education.course.common.req.TopicREQ;
import com.roncoo.education.course.service.api.biz.ApiCourseTopicBiz;
import com.roncoo.education.course.service.dao.impl.mapper.entity.CourseTopic;
import com.roncoo.education.course.service.dao.impl.mapper.entity.Topic;
import com.roncoo.education.util.annotation.RequestRequire;
import com.roncoo.education.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/course/api/course/topic")
@Api(tags = "钉钉-问卷调查 考试")
@AllArgsConstructor
public class ApiCourseTopicController {

    private final ApiCourseTopicBiz courseTopicBiz;

    @PostMapping("/questionnaire/list")
    @ApiOperation(value = "问卷列表", notes = "问卷列表")
    public Result<Page<CourseTopic>> list() {
        return courseTopicBiz.list();
    }

    @PostMapping("/questionnaire/view")
    @ApiOperation(value = "问卷-题目分页列表", notes = "问卷-题目分页列表")
    public Result<Page<Topic>> topicList(@RequestBody TopicREQ topicREQ) {
        //试卷id：courseTopicId -> 获取试卷所有的题目

        //根据题目id，获取所有答案

        return courseTopicBiz.topicList(topicREQ);
    }

    //问卷-保存提交
//    @ApiOperation(value = "问卷-保存或修改题目", notes = "问卷-保存或修改题目" )
    @RequestMapping(value = "/questionnaire/saveOrUpdate", method = RequestMethod.POST)
    @RequestRequire(require = "courseTopicId,title,topic",parameter = TopicREQ.class)
    public Result saveOrUpdate(@RequestBody TopicREQ topicREQ) {


        return null;
//        return topIcBiz.saveOrUpdate(topicREQ);
    }
}
